package com.kang.servlet;

import com.kang.dao.impl.water_purifierDaoImpl;
import com.kang.entity.water_purifier;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by lenovo on 2018/8/14.
 */
@WebServlet(name = "UpdateWaterServlet")
public class UpdateWaterServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        int wpid=Integer.parseInt(request.getParameter("wpid"));
        String waterName=request.getParameter("waterName");
        String mamufacturer=request.getParameter("mamufacturer");
        String warranty=request.getParameter("warranty");
        String model=request.getParameter("model");
        String approval=request.getParameter("approval");
        String waterYield=request.getParameter("waterYield");
        Double price=Double.parseDouble(request.getParameter("price"));

        water_purifier w=new water_purifier();
        w.setWpid(wpid);
        w.setWaterName(waterName);
        w.setMamufacturer(mamufacturer);
        w.setWarranty(warranty);
        w.setModel(model);
        w.setApproval(approval);
        w.setWaterYield(waterYield);
        w.setPrice(price);
        int i=  new water_purifierDaoImpl().updateWaterById(w);

        out.print(i);
        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request,response);
    }
}
